<!--
//******************************************************************
//* Copyright (c) 2008 Ford Motor Company. All Rights Reserved.
//*
//*
//* $$Workfile:   costStructureFind.jsp  $$
//* $$Revision:   1.0  $$
//* $$Author:   JLOPE262  $$
//* $$Date:   Nov 14 2008 08:57:48  $$
//*
//* Description: Description of file goes here
//******************************************************************
-->
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://displaytag.sf.net/el" prefix="display-el" %>
<%@ taglib uri="ford-arg/tags" prefix="ft" %>

<script language="JavaScript" src="./scripts/popups.js"></script>
<script language="JavaScript" src="./scripts/ajaxSearch.js"></script>

<script language="javascript">
	
	function lookupSupplier() {
		searchNameSupplier("lookupedSupplier", "supplierCode", "supplierClass");
	}
	
	function lookupPart() {
		searchNamePart("lookupedPart", "partClass", "partPrefix", "partBase", "partSuffix");
	}
	
	function costStructureFind() {
		document.CostStructureFindForm.action = "CostStructureFindActionFind.do";
		document.CostStructureFindForm.section.value = "find";
		document.CostStructureFindForm.submit();	
	}
	
	function costStructureNew() {
		document.CostStructureFindForm.action = "CostStructureNewActionInit.do";
		document.CostStructureFindForm.section.value = "newCostStr";
		document.CostStructureFindForm.submit();			
	}
	
	function costStructureVersionNew() {
		document.CostStructureFindForm.action = "CostStructureFindActionNewVersion.do";
		document.CostStructureFindForm.section.value = "newVersion";
	}
	
	function costStructureCopyTo() {
		document.CostStructureFindForm.action = "CostStructureFindActionCopyTo.do";
		document.CostStructureFindForm.section.value = "copyTo";	
	}
	
	function fullEconomics() {
	}
	
	function printCostStructure() {
	}
	
	function viewMacropartInfo() {	
	}
	
	function selectOne(num){
		for(i=0; i<document.CostStructureFindForm.elements.length; i++){
			/*var name = document.CostStructureFindForm.elements[i].name.split('(');
			if(name[0]=='selecMapped'){
				if(name[1].split(')')[0] != num)
				document.CostStructureFindForm.elements[i].checked=false;
			}*/
			var elemento = document.CostStructureFindForm.elements[i];
			if(elemento.name=='selectedIndex'){
				if(elemento.value != num)
					elemento.checked=false;
			}						
		}
		//document.CostStructureFindForm.selectedIndex.value=num;
	}
	
	function editCostStructureVersion() {
		document.CostStructureFindForm.action = "CostStructureFindActionEdit.do";
		document.CostStructureFindForm.section.value = "edit";
	}
	
	function headerCostStructureVersion() {
		document.CostStructureFindForm.action = "CostStructureFindActionHeader.do";
		document.CostStructureFindForm.section.value = "header";		
	}
	
	function deleteCostStructureVersion() {
		document.CostStructureFindForm.action = "CostStructureFindActionDelete.do";
		document.CostStructureFindForm.section.value = "deleteCostStrVersion";
	}
	
	function confirmDeleteCostStrVersion(del){
		if (del) {
			document.CostStructureFindForm.action = "CostStructureDefActionDeleteSubCSItem.do";
			document.CostStructureFindForm.section.value = "deleteCostStrVersionConfirmed";
			document.CostStructureFindForm.submit();
		}
	}		
	
	function proposeCostStructureFromList() {
		document.CostStructureFindForm.action = "CostStructureFindActionPropose.do";
		document.CostStructureFindForm.section.value = "propose";	
	}
	
	function approveCostStructureFromList() {
		document.CostStructureFindForm.action = "CostStructureFindActionApprove.do";
		document.CostStructureFindForm.section.value = "approve";	
	}
	
	function clean() {
		document.CostStructureFindForm.action = "CostStructureFindActionClean.do";
		document.CostStructureFindForm.section.value = "clean";			
		document.CostStructureFindForm.submit();		
	}
	
</script>

<table>
	<tr>
		<td colspan="2"><h2><bean:message key="costStructure.find.label.title"/></h2></td>
	</tr>
</table>
<br/>
<html:form action="/CostStructureFindActionInit">
<html:hidden property="section"/>
	
	<bean:define id="idTitle">
		<bean:message key="costStructure.label.tableHeader.id" />
	</bean:define>
	<bean:define id="supplierTitle">
		<bean:message key="costStructure.label.tableHeader.supplier" />
	</bean:define>
	<bean:define id="appliesToTitle">
		<bean:message key="costStructure.label.tableHeader.appliesTo" />
	</bean:define>
	<bean:define id="versionTitle">
		<bean:message key="costStructure.label.tableHeader.version" />
	</bean:define>
	<bean:define id="statusTitle">
		<bean:message key="costStructure.label.tableHeader.status" />
	</bean:define>
	<bean:define id="effDateInTitle">
		<bean:message key="costStructure.label.tableHeader.effDateIn" />
	</bean:define>
	<bean:define id="effDateOutTitle">
		<bean:message key="costStructure.label.tableHeader.effDateOut" />
	</bean:define>		
	<bean:define id="creationTitle">
		<bean:message key="costStructure.label.tableHeader.creation" />
	</bean:define>
	<bean:define id="proposalTitle">
		<bean:message key="costStructure.label.tableHeader.proposal" />
	</bean:define>	
	<bean:define id="approvalTitle">
		<bean:message key="costStructure.label.tableHeader.approval" />
	</bean:define>
	<bean:define id="obsTitle">
		<bean:message key="costStructure.label.tableHeader.obs" />
	</bean:define>
	<bean:define id="actionsTitle">
		<bean:message key="costStructure.label.tableHeader.actions" />
	</bean:define>
	<bean:define id="selectTitle">
		<bean:message key="costStructure.label.tableHeader.select" />
	</bean:define>
	
	<table>
		<tr>
			<td>
				<table>
					<tr>
						<td class="text_blue_bold align_left">							
							<bean:message key="costStructure.find.supplier"/>
						</td>
						<td class="align_left">
							<html:select property="supplierTypeSel" styleId="supplierClass">
								<html:option value="-1" key="label.anyOption" />
								<html:options collection="supplierTypeCol" property="value" labelProperty="label" />
							</html:select>
							&minus;
							<html:text property="supplierCode" maxlength="6" size="6" styleId="supplierCode" />
							<html:button property="lookupSupp" onclick="lookupSupplier();" styleClass="button">...</html:button>
							<html:button property="findSupp" onclick="findSupplierPopup('supplierClass', 'supplierCode');" styleClass="button" style="width:25px;">?</html:button>
							<%--bean:write name="CostStructureFindForm" property="lookupedSupplier" /--%>
							<div style="display:inline;" id="lookupedSupplier" />
						</td>
						<td class="text_blue_bold align_right">
							<bean:message key="costStructure.find.label.status" />
							<html:select property="statusSel">
								<html:option value="-1" key="label.allOption" />
								<html:options collection="statusCol" property="value" labelProperty="label" />
							</html:select>
						</td>
					</tr>
					<tr>
						<td class="text_blue_bold align_left">
							<%--html:radio property="findBy" value="commodity" /--%>
							<bean:message key="commodity.label" />
						</td>
						<td class="align_left">
							<html:select property="commoditySel">
								<html:option value="-1" key="label.allOption"/>
								<html:options collection="commoditiesCol" property="eesp02CommodityNumberK" labelProperty="eesp02CommodityNameN" />
							</html:select>
						</td>
						<td class="text_blue_bold align_right">
							<html:checkbox property="showLastApprovedOnly" value="true" />							
							<bean:message key="costStructure.find.label.showLastApprovedOnly" />
						</td>					
					</tr>
					<tr>
						<td class="text_blue_bold align_left">
							<%--html:radio property="findBy" value="part" /--%>
							<bean:message key="part.label" />
						</td>
						<td class="align_left" colspan="2">
							<html:select property="partClassSel" styleId="partClass">
								<html:option value="-1"><bean:message key="label.anyOption" /></html:option>
								<html:options collection="partClassesCol" property="value" labelProperty="label" />
							</html:select>
							&minus;
							<html:text property="partPrefix" maxlength="10" size="10" styleId="partPrefix"/>
							&nbsp;
							<html:text property="partBase" maxlength="10" size="10" styleId="partBase"/>
							&nbsp;
							<html:text property="partSufix" maxlength="10" size="10" styleId="partSuffix"/>
							<html:button property="lookPart" onclick="lookupPart();" styleClass="button">...</html:button>
							<html:button property="findP" onclick="findPartPopup('supplierClass', 'supplierCode', 'partClass', 'partPrefix', 'partBase', 'partSuffix');" styleClass="button" style="width:25px;">?</html:button>
							<%--bean:write name="CostStructureFindForm" property="lookupedPart" /--%>
							<div style="display:inline;" id="lookupedPart" />
						</td>					
					</tr>
					<tr>
						<td class="text_blue_bold align_left" colspan="3">
							<bean:message key="costStructure.find.label.date" />
							<html:select property="dateTypeSel">
								<html:options collection="dateTypesCol" property="value" labelProperty="label" />
							</html:select>
							<bean:message key="costStructure.find.label.between" />
							<html:text property="dateMin" maxlength="10" size="10" />
							<bean:message key="label.and" />
							<html:text property="dateMax" maxlength="10" size="10" />
							&nbsp;&nbsp;
							<bean:message key="label.user" />
							<html:select property="userActionTypeSel">
								<html:options collection="userActionsTypesCol" property="value" labelProperty="label" />
							</html:select>
							<html:text property="userId" size="8" maxlength="8" />
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<html:button property="cleanScreen" onclick="clean();" styleClass="button"><bean:message key="label.clean" /></html:button>							
							<html:button property="findCostStructure" onclick="costStructureFind();" styleClass="button"><bean:message key="label.find" /></html:button>
						</td>
					</tr>
				</table>
			</td>		
		</tr>
	<logic:equal name="CostStructureFindForm" property="section" value="confirmDeleteCostStrVersion">
		<tr>
			<td colspan="100%">
				<div class="messagescontent_error align_center" style="width:400px;" >
					<table class="messages" cellspacing="0">
						<tr>
							<td class="messagescontent_error" colspan="2"><bean:message key="costStructure.find.message.confirmCostStrVersionDelete"/></td>
						</tr>
						<tr>
							<td class="messagescontent_error" align="center"><html:button property="yes" styleClass="button_small" style="width:50px;" onclick="confirmDeleteCostStrVersion(true);" ><bean:message key="label.yes"/></html:button></td>
							<td class="messagescontent_error" align="center"><html:button property="no" styleClass="button_small" style="width:50px;" onclick="confirmDeleteCostStrVersion(false);" ><bean:message key="label.no"/></html:button></td>
						</tr>
					</table>
				</div>				
			</td>
		</tr>
	</logic:equal>		
		<tr>
			<td style="height:15px;" />
		</tr>		
		<tr>
			<td>
				<table>
					<tr>
						<td class="align_left">
							<html:button property="newCostStructure" onclick="costStructureNew();" styleClass="button"><bean:message key="label.new" /></html:button>
							<html:submit property="newCostStructureVersion" onclick="costStructureVersionNew();" styleClass="button"><bean:message key="costStructure.find.label.newVersion" /></html:submit>
							<html:submit property="copyTo" onclick="costStructureCopyTo();" styleClass="button"><bean:message key="costStructure.find.label.copyTo" /></html:submit>
							<html:button property="fullEcon" onclick="fullEconomics();" styleClass="button"><bean:message key="costStructure.find.label.fullEconomics" /></html:button>
							<html:button property="print" onclick="printCostStructure();" styleClass="button"><bean:message key="label.print" /></html:button>
							<html:button property="macropartInfo" onclick="viewMacropartInfo();" styleClass="button"><bean:message key="costStructure.find.label.viewMacropartInfo" /></html:button>							
						</td>
					</tr>
					<tr>
						<td>
							<ft:saveActivePageNumber />
							<display-el:table 	class="table1" style="width: 800px;" cellpadding="5" uid="csVersion"
												name="sessionScope.CostStructureFindForm.costStructureVersions"  pagesize="15"
												excludedParams="*" requestURI="CostStructureFindActionPaginate.do">
								<display-el:column title="${idTitle}" property="teesc01Coststruct.eesc01CststrNumberK" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right"/>
								<display-el:column title="${versionTitle}" property="eesc02CststvVersionNumberK" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right"/>
								<display-el:column title="${supplierTitle}" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">
									${ csVersion.teesc01Coststruct.teess01Supplier.eess01SupplierClassCodeC }&nbsp;&minus;
									${ csVersion.teesc01Coststruct.teess01Supplier.eess01SupplierCodeC }&nbsp;&minus;
									${ csVersion.teesc01Coststruct.teess01Supplier.eess01SupplierNameN }
								</display-el:column>
								
								<display-el:column title="${appliesToTitle}" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">
									<logic:equal name="csVersion" property="teesc01Coststruct.eesc01CststrTypeCodeC" value="S"><bean:message key="costStructure.find.supplier" /></logic:equal>
									<logic:equal name="csVersion" property="teesc01Coststruct.eesc01CststrTypeCodeC" value="C"><bean:message key="commodity.label" /></logic:equal>
									<logic:equal name="csVersion" property="teesc01Coststruct.eesc01CststrTypeCodeC" value="P"><bean:message key="part.label" /></logic:equal>
								</display-el:column>
								
								<display-el:column title="" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">
									<logic:equal name="csVersion" property="teesc01Coststruct.eesc01CststrTypeCodeC" value="S">*</logic:equal>
									<logic:equal name="csVersion" property="teesc01Coststruct.eesc01CststrTypeCodeC" value="C">
										${ csVersion.teesc01Coststruct.teesp02Commodity.eesp02CommodityNameN }
									</logic:equal>
									<logic:equal name="csVersion" property="teesc01Coststruct.eesc01CststrTypeCodeC" value="P">
										<div title="${ csVersion.teesc01Coststruct.teesp04Supply.teesp01Part.eesp01PartDescriptionX }">
											${ csVersion.teesc01Coststruct.teesp04Supply.teesp01Part.eesp01PartClassCodeC }&nbsp;
											${ csVersion.teesc01Coststruct.teesp04Supply.teesp01Part.eesp01PartPrefixCodeC }&minus;
											${ csVersion.teesc01Coststruct.teesp04Supply.teesp01Part.eesp01PartBaseCodeC }&minus;
											${ csVersion.teesc01Coststruct.teesp04Supply.teesp01Part.eesp01PartSuffixCodeC }
										</div>
									</logic:equal>
								</display-el:column>
								
								<display-el:column title="${statusTitle}" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">
									<logic:empty name="csVersion" property="eesc02CststvProposalUserC">
										<bean:message key="label.draft"/>
									</logic:empty>
									<logic:empty name="csVersion" property="eesc02CststvApprovalUserC">
										<logic:notEmpty name="csVersion" property="eesc02CststvProposalUserC">
											<bean:message key="label.proposed"/>										
										</logic:notEmpty>
									</logic:empty>
									<logic:notEmpty name="csVersion" property="eesc02CststvApprovalS">
										<bean:message key="label.approved"/>
									</logic:notEmpty>																		
								</display-el:column>
								
								<display-el:column title="${effDateInTitle}" property="eesc02CststvInDateY" decorator="ar.com.ford.it.fullEconomics.view.displaytag.DateDecorator" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right"/>
								<display-el:column title="${effDateOutTitle}" property="eesc02CststvOutDateY" decorator="ar.com.ford.it.fullEconomics.view.displaytag.DateDecorator" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right"/>								
								<display-el:column title="${creationTitle}" decorator="ar.com.ford.it.fullEconomics.view.displaytag.CostStructureItemColumnDecorator" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">
									${ csVersion.eesc02CreateUserC }<br />${ csVersion.eesc02CreateS }
								</display-el:column>
								
								<display-el:column title="${proposalTitle}" decorator="ar.com.ford.it.fullEconomics.view.displaytag.CostStructureItemColumnDecorator" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">
									<logic:empty name="csVersion" property="eesc02CststvProposalUserC">
										<html:submit property="csVersionMapped(${csVersion_rowNum})" styleClass="button" onclick="proposeCostStructureFromList();"><bean:message key="label.propose" /></html:submit>
									</logic:empty>
									<logic:notEmpty name="csVersion" property="eesc02CststvProposalUserC">
										${csVersion.eesc02CststvProposalUserC}<br />${csVersion.eesc02CststvProposalS}
									</logic:notEmpty>									
								</display-el:column>
								
								<display-el:column title="${approvalTitle}" decorator="ar.com.ford.it.fullEconomics.view.displaytag.CostStructureItemColumnDecorator" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">
									<logic:notEmpty name="csVersion" property="eesc02CststvProposalUserC">					
										<logic:empty name="csVersion" property="eesc02CststvApprovalUserC">
											<html:submit property="csVersionMapped(${csVersion_rowNum})" styleClass="button" onclick="approveCostStructureFromList();"><bean:message key="label.approve" /></html:submit>
										</logic:empty>
									</logic:notEmpty>
									<logic:notEmpty name="csVersion" property="eesc02CststvApprovalUserC">
										${csVersion.eesc02CststvApprovalUserC}<br />${csVersion.eesc02CststvApprovalS}
									</logic:notEmpty>								
								</display-el:column>
								
								<display-el:column title="${obsTitle}" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">
									<logic:notEmpty name="csVersion" property="eesc02CststvCommentsX">
										<div align="center"><html:img src="images/observation.gif" /></div>
									</logic:notEmpty>
									<logic:empty name="csVersion" property="eesc02CststvCommentsX">
										&nbsp;
									</logic:empty>									
								</display-el:column>
								
								<display-el:column title="${actionsTitle}" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">
									<html:submit property="csVersionMapped(${csVersion_rowNum})" styleClass="button" onclick="editCostStructureVersion();"><bean:message key="label.edit" /></html:submit>&nbsp;
									<html:submit property="csVersionMapped(${csVersion_rowNum})" styleClass="button" onclick="headerCostStructureVersion();"><bean:message key="costStructure.find.label.head" /></html:submit>&nbsp;
									<html:submit property="csVersionMapped(${csVersion_rowNum})" styleClass="button" onclick="deleteCostStructureVersion();"><bean:message key="label.delete" /></html:submit>
								</display-el:column>
								<display-el:column title="${selectTitle}" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">
									<html:checkbox property="selectedIndex" value="${csVersion_rowNum}" onclick="selectOne(${csVersion_rowNum});"/>
									<%--input type="button" name="selecMapped(${csVersion_rowNum})" onclick="selectOne(${csVersion_rowNum});" /--%>
									<%--html:submit property="selecMapped(${csVersion_rowNum})" onclick="costStructureVersionNew();">NV</html:submit>
									<html:submit property="selecMapped(${csVersion_rowNum})" onclick="costStructureCopyTo();">CT</html:submit--%>
								</display-el:column>
							</display-el:table>
						</td>
					</tr>
				</table>			
			</td>		
		</tr>
	</table>
</html:form>
